package com.nslt.controller;

import com.alibaba.fastjson.JSONObject;
import com.nslt.entity.Users;
import com.nslt.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class UsersController {

    @Autowired
    private UsersService usersService;

    @RequestMapping(value="/users",method= RequestMethod.POST)
    @ResponseBody
    public Object add(Users vo){
        //log.info("数据增加成功："+vo);
        System.out.println("数据增加成功："+vo);
        System.out.println("账号："+vo.getActiveStatus());
        JSONObject js = new JSONObject();
        //JSONObject json=new JSONObject();
        js.put("flag", true);
        List<Users> users = new ArrayList<Users>();
        users = usersService.findAllUsers();
        System.out.println(users.size());
        return js;
        //return "index";
    }
}
